/*
 * @Description:  递归实现阶乘
 * @Author: zzj
 * @Date: 2021-09-08 19:53:41
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-08 19:54:44
 */

function factorial(num) {
    //return num*factiol(num-1);
    /*
    * return 10*fa(9)
    *	10*9*fa(8)
    *	10*9*8*7...*fa(2)
    *	10*9*8*7*...*2*fa(1)
    *	10*9*8*7*...*2*1*fa(-1)
    */
    if(num<=1){
        return 1;
    }  else {
      return num * arguments.callee(num-1)  //callee是一个指针，指向拥有arguments对象的函数。
    }
  }
  console.log(factorial(3));